<?php

use Johnm\Probackend\Former\Facades\Former;

$modules = Config::get('probackend::modules', array());

/**
 * =============================================================================
 * Create form content
 * =============================================================================
 */
$create_form_content = '<div class="text-center modal-frontdrop"><i class="icon-spinner3 spin block-inner"></i></div>';


$create_form_content .='<div class="col-sm-4">';
$create_form_content .= '<br><h5>' . translate("probackend::administrator_group.form_create_information") . '</h5>';
$create_form_content .= Former::text("title")
        ->label(Lang::get("probackend::administrator_group.model_group_title"))
        ->maxlength(255)
        ->required();

$create_form_content .= Former::text("name")
        ->label(translate("probackend::administrator_group.model_group_name"))
        ->maxlength(255)
        ->required();
$create_form_content .='</div>';

$create_form_content .= '<div class="col-sm-8">';
$create_form_content .= '<br><h5>' . translate("probackend::administrator_group.form_create_permistion") . '</h5>';
$create_form_content .= '<table class="table">';
foreach ($modules as $moduleID => $module) {
    if ($moduleID === "dashboard")
        continue;
    $create_form_content .= '<thead>';
    $create_form_content .= '<tr class="active">';
    $create_form_content .= '<th colspan=2>';
    $create_form_content .= "Module " . translate($module['title']);
    $create_form_content .= '</th>';
    $create_form_content .= '</tr>';
    $create_form_content .= '</thead>';


    $create_form_content .= '<tbody>';

    foreach ($module['permistions'] as $permistionID => $permistionName) {
        $create_form_content .= '<tr>';

        $create_form_content .= '<td>';
        $create_form_content .= translate($permistionName);
        $create_form_content .= '</td>';

        $create_form_content .= '<td>';
        $create_form_content .= Former::switcher("permissions[$moduleID.$permistionID]", null, 1)->class("switch-small model-create-form-switch");
        $create_form_content .= '</td>';
        $create_form_content .= '</tr>';
    }

    $create_form_content .= '<tbody>';
}
$create_form_content .= '</table>';
$create_form_content.='</div>';
$create_form_content.='<div class="clearfix"></div>';
$create_form_content .= '<script>';
$create_form_content .= "$('#crub-create-model-dialog input[type=\'checkbox\']').bootstrapSwitch();\n";
$create_form_content .= '</script>';

echo $create_form_content;
